package operation;

import car.Bus;
import car.Car;
import car.Cars;
import car.Trunk;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class RentMgrSys implements IOperation {

    @Override
    public void work(Cars cars) {
        Scanner scanner = new Scanner(System.in);

        //通过choice来进行后面的租金计算和车牌选择
        System.out.println("1. 轿车   2. 客车   3. 卡车");
        System.out.print("请选择你要租赁的汽车类型 :");
        int x = scanner.nextInt();
        if (x == 1) {
            carLeaseOut(cars, 1);
        } else if (x == 2) {
            busLeaseOut(cars, 2);
        } else if (x == 3) {
            trunkLeaseOut(cars, 3);
        } else {
            System.out.println("输入错误!!!");
        }
    }

    public void carLeaseOut(Cars cars, int t) {
        Scanner scanner = new Scanner(System.in);
        int choice;
        System.out.println("1. 宝马     2. 别克");
        System.out.print("请选择你要租赁的轿车品牌: ");
        int brand = scanner.nextInt();
        choice = brand;
        if (brand == 1) {
            System.out.println("1. X6    2. 550i");
        } else if (brand == 2) {
            System.out.println("1. 林荫大道 2. GL8");
        } else {
            System.out.println("输入错误!!!");
        }
        System.out.print("请选择你要租赁的轿车型号: ");
        int type = scanner.nextInt();
        if (brand == 1) {
            choice += type - 1;
        } else if (brand == 2) {
            choice += type;
        }
        System.out.print("请选择你要租赁的天数: ");
        int days = scanner.nextInt();

        System.out.println("分配给您的汽车牌号是 :" + cars.getVehicle(t, choice - 1).getVehicleId());
        System.out.println("您需要支付的租赁费用是 : " + cars.getVehicle(t, choice - 1).calRent(days) + "元");
    }

    public void busLeaseOut(Cars cars, int t) {
        Scanner scanner = new Scanner(System.in);
        int choice;
        System.out.println("1. 金杯     2. 金龙");
        System.out.print("请选择你要租赁的客车品牌: ");
        int brand = scanner.nextInt();
        choice = brand;
        if (brand == 1) {
            System.out.println("1. 金杯一    2. 金杯二");
        } else if (brand == 2) {
            System.out.println("1. 金龙一 2. 金龙二");
        } else {
            System.out.println("输入错误!!!");
        }
        System.out.print("请选择你要租赁哪个车: ");
        int type = scanner.nextInt();
        if (brand == 1) {
            choice += type - 1;
        } else if (brand == 2) {
            choice += type;
        }
        System.out.print("请选择你要租赁的天数: ");
        int days = scanner.nextInt();

        System.out.println("分配给您的汽车牌号是 :" + cars.getVehicle(t, choice - 1).getVehicleId());
        System.out.println("您需要支付的租赁费用是 : " + cars.getVehicle(t, choice - 1).calRent(days) + "元");
    }

    public void trunkLeaseOut(Cars cars, int t) {
        Scanner scanner = new Scanner(System.in);
        int choice;
        System.out.println("1. 一汽     2. 雷诺");
        System.out.print("请选择你要租赁的卡车品牌: ");
        int brand = scanner.nextInt();
        choice = brand;
        if (brand == 1) {
            System.out.println("1. 一汽一(10t)    2. 一汽二(20t)");
        } else if (brand == 2) {
            System.out.println("1. 雷诺一(10t) 2. 雷诺二(20t)");
        } else {
            System.out.println("输入错误!!!");
        }
        System.out.print("请输入你需求的卡车承载量(t): ");
        int tmp = scanner.nextInt();
        int type = tmp / 10;
        if (brand == 1) {
            choice += type - 1;
        } else if (brand == 2) {
            choice += type;
        }
        System.out.print("请选择你要租赁的天数: ");
        int days = scanner.nextInt();

        System.out.println("分配给您的汽车牌号是 :" + cars.getVehicle(t, choice - 1).getVehicleId());
        System.out.println("您需要支付的租赁费用是 : " + cars.getVehicle(t, choice - 1).calRent(days) + "元");
    }


}
